package main

import (
	"github.com/kataras/golog"
	//"fmt"
	//"github.com/kataras/golog"
	"github.com/kataras/iris/v12"
	//"goiris/common"

	//"goiris/admin/app/bindata/conf"
	//"goiris/admin/app/bindata/static"
	//"goiris/admin/app/middleware/auth"
	//"goiris/admin/app/middleware/jwt"
	//"goiris/admin/app/middleware/sockets"
	//"goiris/admin/app/web/router"
	//"goiris/common"
	//"goiris/common/storage"
	//"goiris/common/support"
	"github.com/iris-contrib/swagger/v12"              // swagger middleware for Iris
	"github.com/iris-contrib/swagger/v12/swaggerFiles" // swagger embed files
	_ "goiris/admin/docs"
)

/**
 * 项目地址：https://gitee.com/yhm_my/go-iris
 */
// @title Swagger Example API
// @version 1.0
// @description This is a sample server Petstore server.
// @termsOfService http://swagger.io/terms/

// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io

// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html

// @host localhost:8080
// @BasePath /
func main() {
	//common.InitConfig(conf.Asset)
	//support.InitLog()
	//support.InitValidator()
	//storage.InitGorm()
	//storage.InitRedis()
	//auth.InitAuth()
	//jwt.InitJWT()

	app := iris.New()
	config := &swagger.Config{
		URL: "http://localhost:8080/swagger/doc.json", //The url pointing to API definition
	}
	// use swagger middleware to
	app.Get("/swagger/{any:path}", swagger.CustomWrapHandler(config, swaggerFiles.Handler))

	if err := app.Run(iris.Addr(":8080")); err != nil {
		golog.Fatalf("Start admin server failed. And err:%s", err.Error())
	}

	// Websocket
	//sockets.InitWebsocket(app)
	//// HTTP
	//router.Hub(app)
	//if !common.G_AppConfig.Separate {
	//	app.RegisterView(iris.HTML("./resources", ".html").Binary(static.Asset, static.AssetNames))
	//	app.HandleDir("/", "./resources", iris.DirOptions{
	//		//IndexName:  "/index.html", // default "/index.html"
	//		Asset:      static.Asset,
	//		AssetNames: static.AssetNames,
	//		AssetInfo:  static.AssetInfo,
	//	})
	//}
	// Start web server
	//if err := app.Run(
	//	iris.Addr(fmt.Sprintf(":%d", common.G_AppConfig.Port)),
	//	iris.WithConfiguration(common.G_AppConfig.Configuration)); err != nil {
	//	golog.Fatalf("Start admin server failed. And err:%s", err.Error())
	//}
}
